﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using EXT;

namespace BanHangCshap.Class.gkhtdl63.DAL
{
    public abstract class Phieuxuat2DAL:clsBaseDAL
    {
        public DataTable Phieuxuat2_Laydanhsach()
        {
            return base.Select("sp_Phieuxuat2_Laydanhsach");
        }

        public DataTable Phieuxuat2_Laycodieukien(int Loai,object Tungay, object Denngay, object Id_Khachhang2)
        {
            string xlSPName = "sp_Phieuxuat2_Laycodieukien";
            string[] xlSPPara = { "@Loai","@Tungay", "@Denngay", "@Id_Khachhang2" };
            object[] xlSPValu = { Loai,Tungay.ToDateTimeSS(), Denngay.ToDateTimeEE(), Id_Khachhang2 };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Phieuxuat2_LayTheoId(long Id)
        {
            string xlSPName = "sp_Phieuxuat2_LayTheoId";
            string[] xlSPPara = { "@Id" };
            object[] xlSPValu = { Id};
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Phieuxuat2_Them(DAL.Entities.Phieuxuat2 xlPX2)
        {
            string xlSPName = "sp_Phieuxuat2_Them";
            string[] xlSPPara = { "@Ngay"
                                    ,"@Ma"
                                    ,"@Ma_NhanvienLap"
                                    ,"@Id_Khachhang2"
                                    ,"@Tongtien"
                                    ,"@CK"
                                    ,"@Thanhtoan"
                                    ,"@Ghichu"
                                    ,"@Ma_NhanvienGiao"
                                    ,"@Loai"
                                    };
            object[] xlSPValu = { xlPX2.Ngay
                                    ,xlPX2.Ma
                                    ,xlPX2.Ma_NhanvienLap
                                    ,xlPX2.Id_Khachhang2
                                    ,xlPX2.Tongtien
                                    ,xlPX2.CK
                                    ,xlPX2.Thanhtoan
                                    ,xlPX2.Ghichu
                                    ,xlPX2.Ma_NhanvienGiao
                                    ,xlPX2.Loai
                                    };
            return base.InsertReturnObj(xlSPName, xlSPPara, xlSPValu);
        }

        public bool Phieuxuat2_Capnhat(DAL.Entities.Phieuxuat2 xlPX2)
        {
            string xlSPName = "sp_Phieuxuat2_Capnhat";
            string[] xlSPPara = { "@Id","@Ngay"
                                    ,"@Ma"
                                    ,"@Ma_NhanvienLap"
                                    ,"@Id_Khachhang2"
                                    ,"@Tongtien"
                                    ,"@CK"
                                    ,"@Thanhtoan"
                                    ,"@Ghichu"
                                    ,"@Ma_NhanvienGiao"
                                    };
            object[] xlSPValu = { xlPX2.Id,xlPX2.Ngay
                                    ,xlPX2.Ma
                                    ,xlPX2.Ma_NhanvienLap
                                    ,xlPX2.Id_Khachhang2
                                    ,xlPX2.Tongtien
                                    ,xlPX2.CK
                                    ,xlPX2.Thanhtoan
                                    ,xlPX2.Ghichu
                                    ,xlPX2.Ma_NhanvienGiao
                                    };
            return base.Update(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Phieuxat2_Taoma(string xlPMa)
        {
            string xlSPName = "sp_Phieuxuat2_Taoma";//sp_Phieuxuat2_Taoma
            string[] xlSPPara = { "@PMa"};
            object[] xlSPValu = { xlPMa};
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public bool Phieuxuat2_Xoa(long Id)
        {
            string xlSPName = "sp_Phieuxuat2_Xoa";//sp_Phieuxuat2_Taoma
            string[] xlSPPara = { "@Id" };
            object[] xlSPValu = { Id };
            return base.Delete(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Phieuxuat2_TinhNocuKhachhangK(DateTime Ngay, long Id_Khachhang2)
        {
            string xlSPName = "sp_Khachang2_TinhnocuK";//sp_Phieuxuat2_Taoma
            string[] xlSPPara = { "@Ngay", "@Id_Khachhang2" };
            object[] xlSPValu = { Ngay,Id_Khachhang2 };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Phieuxuat2_TinhNocuKhachhangN(DateTime Ngay, long Id_Khachhang2)
        {
            string xlSPName = "sp_Khachang2_TinhnocuN";//sp_Phieuxuat2_Taoma
            string[] xlSPPara = { "@Ngay", "@Id_Khachhang2" };
            object[] xlSPValu = { Ngay, Id_Khachhang2 };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable Phieuxuat2_In(long Id)
        {
            string xlSPName = "sp_Phieuxuat2_In";
            string[] xlSPPara = { "@Id" };
            object[] xlSPValu = { Id };
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public DataTable ResCount()
        {
            return base.Select("sp_Count");
        }
    }
}
